package ${(introspectedTable.tableConfiguration.properties.fileDirectoryController)?substring(((introspectedTable.tableConfiguration.properties.fileDirectoryController)?index_of("/src/main/java/")+15))?replace("/",".")};

import com.broker.framework.common.pojo.CommonResult;
import com.broker.framework.repeat.core.annotation.RepeatSubmit;
import com.broker.framework.security.core.annotations.PreAuthenticated;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/***
 * ---------------------------
 * @Description: 表备注：${introspectedTable.remarks!}<#--deal null-->
 * 针对表【${introspectedTable.tableConfiguration.schema!}.${introspectedTable.fullyQualifiedTable.introspectedTableName}】的Controller
 * ---------------------------
 * @author: ${introspectedTable.tableConfiguration.properties.auther!}
 * @date: ${introspectedTable.tableConfiguration.properties.createTime!}
 * @version: v1.0
 * ---------------------------
 */
@Tag(name = "${introspectedTable.remarks!}")
@RestController
@Validated
@RequestMapping("/${introspectedTable.fullyQualifiedTable.introspectedTableName?replace("_","-")}")
@Slf4j
public class ${className}Controller {

    @Resource
    private ${className}Service ${classNameTuoFeng}Service;

    @PreAuthenticated
    @GetMapping("/get/{id}")
    @Operation(summary = "获取单个")
    @Parameter(name = "id", description = "id", required = true)
    @Valid
    public CommonResult<${className}GetRespVO> get(@NotNull(message = "id不能为空") @PathVariable(value = "id") Long id) {
        return ${classNameTuoFeng}Service.get(id);
    }

    @RepeatSubmit
    @PreAuthenticated
    @PostMapping("/add")
    @Operation(summary = "新增")
    public CommonResult<Object> add(@RequestBody @Valid ${className}AddReqVO reqVO) {
        return ${classNameTuoFeng}Service.add(reqVO);
    }

    @RepeatSubmit
    @PreAuthenticated
    @PostMapping("/update")
    @Operation(summary = "修改")
    public CommonResult<Object> update(@RequestBody @Valid ${className}UpdateReqVO reqVO) {
        return ${classNameTuoFeng}Service.update(reqVO);
    }


    @RepeatSubmit
    @PreAuthenticated
    @PostMapping("/delete")
    @Operation(summary = "删除")
    public CommonResult<Object> delete(@RequestBody @Valid ${className}DeleteReqVO reqVO) {
        return ${classNameTuoFeng}Service.delete(reqVO);
    }


}